﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace SMP.Resource
{
    using SMP.Domain;
    public class Nha_Cungcap_Res : BaseDB
    {
        public DataTable GetAll_Nha_Cungcap()
        {
            return ExecuteQuery("EXEC GetAll_Nha_Cungcap ");
        }

        public bool Get_Nha_Cungcap_Check_Used_By_Id_Nha_Cungcap(long id_nha_cungcap)
        {
            string sql = @"EXEC Get_Nha_Cungcap_Check_Used_By_Id_Nha_Cungcap {0}";
            sql = string.Format(sql, id_nha_cungcap);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }

        public bool Delete_Nha_Cungcap(long id_nha_cungcap)
        {
            string sql = string.Format(@"DELETE FROM tb_nha_cungcap WHERE id_nha_cungcap = {0}", id_nha_cungcap);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }

        public bool Insert_Nha_Cungcap(Nha_Cungcap nha_cungcap)
        {
            string sql = string.Format(@"INSERT INTO tb_nha_cungcap(ten_nha_cungcap, dienthoai, diachi, email, ghichu) VALUES (N'{0}', '{1}', N'{2}', '{3}', N'{4}')",
                                                            nha_cungcap.Ten_Nha_Cungcap, nha_cungcap.Dienthoai, nha_cungcap.Diachi, nha_cungcap.Email, nha_cungcap.Ghichu);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }

        public bool Update_Nha_Cungcap(Nha_Cungcap nha_cungcap)
        {
            string sql = string.Format(@"UPDATE tb_nha_cungcap SET ten_nha_cungcap = N'{0}', dienthoai = '{1}', diachi = N'{2}', email = '{3}', ghichu = N'{4}')",
                                                            nha_cungcap.Ten_Nha_Cungcap, nha_cungcap.Dienthoai, nha_cungcap.Diachi, nha_cungcap.Email, nha_cungcap.Ghichu);
            return ExecuteNonQuery(sql) > 0 ? true : false;
        }





    }
}
